package com.digitalchina.lxnsy.activity.old;

import android.content.Intent;

import com.digitalchina.lxnsy.R;
import com.digitalchina.lxnsy.base.BaseActivity;
import com.digitalchina.lxnsy.toolkit.ActivityTaskManager;
import com.digitalchina.lxnsy.toolkit.AppInfo;
import com.digitalchina.lxnsy.xml.CommonXML;
import com.digitalchina.lxnsy.xml.UserXML;

import cn.bingoogolapple.bgabanner.BGABanner;

import static com.digitalchina.lxnsy.toolkit.Utils.setTitleBarTranslucent;

public class GuideActivity extends BaseActivity {
    private BGABanner mBackgroundBanner;
    private BGABanner mForegroundBanner;


    @Override
    protected void onResume() {
        super.onResume();
        // 如果开发者的引导页主题是透明的，需要在界面可见时给背景 Banner 设置一个白色背景，避免滑动过程中两个 Banner 都设置透明度后能看到 Launcher
        mBackgroundBanner.setBackgroundResource(android.R.color.white);
    }

    @Override
    public void setLayout() {
        setContentView(R.layout.activity_guide);
    }

    public void initMember() {

        setTitleBarTranslucent(this);
        mBackgroundBanner = (BGABanner) findViewById(R.id.banner_guide_background);
        mForegroundBanner = (BGABanner) findViewById(R.id.banner_guide_foreground);

    }

    @Override
    public void addListener() {
        /**
         * 设置进入按钮和跳过按钮控件资源 id 及其点击事件
         * 如果进入按钮和跳过按钮有一个不存在的话就传 0
         * 在 BGABanner 里已经帮开发者处理了防止重复点击事件
         * 在 BGABanner 里已经帮开发者处理了「跳过按钮」和「进入按钮」的显示与隐藏
         */
        mForegroundBanner.setEnterSkipViewIdAndDelegate(R.id.btn_guide_enter, R.id.tv_guide_skip, new BGABanner.GuideDelegate() {
            @Override
            public void onClickEnterOrSkip() {
                if (!ActivityTaskManager.getInstance().hasActivity(MainActivity.class)) {
                    CommonXML.setIsFirstOpenStatus(GuideActivity.this, UserXML.USER_IS_LOGIN_VALUE);
                    CommonXML.setVersionCode(GuideActivity.this, String.valueOf(AppInfo.getVersionCode(GuideActivity.this)));
                    startActivity(new Intent(GuideActivity.this, MainActivity.class));
                }
                finish();
            }
        });


        // 设置数据源
        mBackgroundBanner.setData(R.drawable.uoko_guide_background_1, R.drawable.uoko_guide_background_2);

        mForegroundBanner.setData(R.drawable.uoko_guide_foreground_1, R.drawable.uoko_guide_foreground_2);
    }

    @Override
    public void setHandler() {

    }

    @Override
    public void callBack(Object object) {

    }

    @Override
    public void rightOnClick() {

    }
}